package com.example.wu.demob;

import android.content.Intent;
import android.support.v7.app.AppCompatActivity;
import android.os.Bundle;
import android.view.View;
import android.widget.Button;

public class MainActivity extends AppCompatActivity {
    private Button btn1;
    private Button btn2;
    @Override
    protected void onCreate(Bundle savedInstanceState) {
        super.onCreate(savedInstanceState);
        setContentView(R.layout.activity_main);

        btn1 = findViewById(R.id.btn_xian2);
        btn2 = findViewById(R.id.btn_yin2);

        /*显式*/
        btn1.setOnClickListener(new View.OnClickListener() {
            @Override
            public void onClick(View v) {
                Intent intent = new Intent();
                intent.setClassName("com.example.wu.demoa",
                        "com.example.wu.demoa.SecondActivity");
                startActivity(intent);
            }
        });

        /*隐式*/
        btn2.setOnClickListener(new View.OnClickListener() {
            @Override
            public void onClick(View v) {
                Intent intent = new Intent("com.example.wu.demoa.ACTION_START");
                /*"android.intent.category.LAUNCHER"是一种默认的Category，
                每个只能指定intent一个action，却能指定多个Category，如下*/
                intent.addCategory("com.example.wu.demoa.MY_CATEGORY");
                startActivity(intent);
            }
        });
    }
}
